package com.xin.webviewcontent;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.xin.libhtmlcontent.tv.OnImgCallBack;
import com.xin.libhtmlcontent.tv.TextViewHtmlContent;

import java.util.List;

public class TextDemo extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tv_demo);
//        new Handler().postDelayed(() -> init(), 1000);
        init();

    }

    private void init() {
        String str = "<div>\n" +
//                "<div>11111</div>\n" +
                "<img src=\"http://fuboapp.com//upload//image//20190930//1569852193570213.png\">\n" +
//                "<div>11111</div>\n" +
                "<img src=\"http://fuboapp.com//upload//image//20190930//1569852193570213.png\">\n" +
//                "<div>11111</div>\n" +
                "<img src=\"http://fuboapp.com//upload//image//20190930//1569852193570213.png\">\n" +
                "</div>";
        TextViewHtmlContent tv = (TextViewHtmlContent) findViewById(R.id.tv);
        tv.setHtmlContent(str);
        tv.setOnImgCallBack(new OnImgCallBack() {
                                @Override
                                public void onImgClick(List<String> ls, int position) {
                                    log("onImgClick() called with: ls = [" + ls + "], position = [" + position + "]");
                                }
                            }
        );
    }

    private void log(String s) {
        System.out.println(s);
    }
}
